﻿
<p>
	<label for="t1">不用timer</label><input type="text" id="t1" value="不用timer" ></input>
</p>
<p>
	<label for="t2">使用timer</label><input type="text" id="t2" value="使用timer" ></input>
</p>
<p style="height:200px;">
	<label for="t3">测试keypress</label><input type="text" id="t3" value=""></input>
	<span id="_t3" class="t3_span"></span><span id="__t3"class="t3_span"></span>
</p>
<p>
	<label for="t4">事件干扰 timeintervel:</label><input id="t4" type="button" value="fibonacci(100)"></input> <span id="_t4_hint"></span>
	<span id="_t4" style="font-size:1.5em; border: 1px dashed black;margin-left:100px;">
		<span id="_t4_h"></span><span style="width:10px;margin:0 auto;">:</span><span id="_t4_m"></span><span style="width:10px;margin:0 auto;">:</span><span id="_t4_s"></span>
	</span>
</p>
<style>

.t3_span{
	border: 1px dashed red;
	padding:5px;
	margin:10px;
	height:120px;
	width:100px;
}
p{background-color:#EEE;height:80px;padding:10px;}
</style>
<script>
	///////////////////////////////////-------t1--------///////////////////
	var t1 = document.createElement("input");
	t1.type="text";
	t1.value="TEST";
	document.getElementsByTagName("p")[0].appendChild(t1);
	t1.focus();
	t1.select();
	///////////////////////////////////-------t2--------///////////////////
	var t2 = document.createElement("input");
	t2.type="text";
	t2.value="TEST2";
	document.getElementsByTagName("p")[1].appendChild(t2);
	setTimeout(function(){
		t2.focus();
		t2.select();
	}, 0);
	///////////////////////////////////-------t3--------///////////////////
	g("t3").onkeypress = function(e){
		g("_t3").innerHTML = this.value;
		setTimeout(function(){g("__t3").innerHTML = g("t3").value;}, 0);
	}
	///////////////////////////////////-------t4--------///////////////////
	var d = new Date();
	g("_t4_h").innerHTML = d.getHours();
	g("_t4_m").innerHTML = d.getMinutes();
	g("_t4_s").innerHTML = d.getSeconds();
	window.setInterval(function(){
		var m = g("_t4_m"), s = g("_t4_s");
		var mm = parseInt(m.innerHTML);
		var ss = parseInt(s.innerHTML);
		if(ss<60){
			s.innerHTML = ++ss;
		}else{
			s.innerHTML = 0;
			m.innerHTML = ++mm;
		}
	}, 1000);
	
	g("t4").onclick = function(){_t4_hint.innerHTML = eval(this.value)}
	///////////////////////////////////-------公用函数--------///////////////////
	function g(id){return document.getElementById(id);}
	function fibonacci(n){
		return n<2 ? 1 : (fibonacci(n-1) + fibonacci(n-2));
	}
</script>